Book Contents

Logical operators in expressions

Logical operators determine the validity of one or more statements. The operators return a value of 1 (or another non-zero value) if the expression is true, or a value of 0 if false. There are three logical operators: AND, OR, and NOT.

Symbols

Operator

Example

AND, &&

and

(tag1 < tag 2) AND (tag1 == 5)

OR, ||

or

(tag1 == 5) OR (tag1 ==10)

NOT

negation

NOT(tag1 > tag2)

Tip:

  • The parentheses are essential in the above expressions.
  • Any statement which evaluates to a non-zero value is regarded as true. For example, the statement tag1 will be false if the value of tag1 is 0, and true if tag1 has any other value.

See also

About expressions

Example: Logical operators

Logical AND

Logical OR

Logical NOT